#!/bin/bash

USER=root
PASSWORD=1
DBNAME=ssauevents

echo "create db"
mysqladmin -u$USER -p$PASSWORD drop   $DBNAME
mysqladmin -u$USER -p$PASSWORD create $DBNAME

echo "add user to new db"
mysql -u$USER -p$PASSWORD -e "GRANT ALL PRIVILEGES ON $DBNAME.* TO 'ssauevents_user'@'localhost' IDENTIFIED BY 'qwerty' WITH GRANT OPTION;"

echo "load tables scheme into db"
mysql -u$USER -p$PASSWORD -D$DBNAME  -e "source create_tables.sql;"

# upload dir
chmod 777 images/
